package com.zwh.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.zwh.dao.AdminDAO;
import com.zwh.entity.Admin;
import com.zwh.entity.PageDTO;
@Service("adminService")
@Transactional
public class AdminServiceImpl implements AdminService {
	@Resource
	private AdminDAO adminDAO;
	@Override
	@Transactional(readOnly=true,propagation=Propagation.SUPPORTS)
	public PageDTO<Admin> selectAdmin(int pageSize, int pageIndex) {
		PageDTO<Admin> pageDTO = new PageDTO<Admin>();
		int start=pageIndex*pageSize-pageSize;
		pageDTO.setRows(adminDAO.selectAdmin(start,pageSize));
		pageDTO.setTotal(adminDAO.count());
		
		return pageDTO;
	}

	@Override
	public void updatePower(Integer id, Integer power) {
		
		adminDAO.updatePower(id, power);
	}

	@Override
	public void updatePassword(Integer id, String password) {
		adminDAO.updatePassword(id, password);

	}

	@Override
	public void addAdmin(Admin admin) {
		adminDAO.addAdmin(admin);

	}

	@Override
	public void deleteAdmin(Integer id) {
		adminDAO.deleteAdmin(id);
		

	}

	@Override
	public void deleteAdmins(Integer[] ids) {
		// TODO Auto-generated method stub

	}

	@Override
	public Admin selectAdminByNP(String username, String password) {
		
		return adminDAO.selectAdminByNP(username, password);
	}
}
